﻿using System.Collections.Generic;
using Ycg.Utility;

namespace Ycg.Logging.Formatters
{
    public class FormatterFactory
    {
        private static Dictionary<LogFormat, LogFormatter> FormatterInstances = new Dictionary<LogFormat, LogFormatter>();

        public static LogFormatter GetInstance(LogFormat logFormat)
        {
            if (!FormatterInstances.ContainsKey(logFormat))
            {
                string fullName = string.Format("Ycg.Logging.Formatters.{0}LogFormatter", logFormat);
                FormatterInstances.Add(logFormat, ObjectHelper.CreateInstance<LogFormatter>(fullName));
            }
            return FormatterInstances[logFormat];
        }
    }
}
